<template>
	<view class="one_main">
		<view class="no_html" v-if="list.length==0">
			<image src="@/static/images/no_img2.png" mode=""></image>
			<text>暂无商品信息</text>
		</view>
		<scroll-view v-else scroll-y="true" class="scroll-Y" @scrolltolower='scrolltolower'>
			<view class="list" v-for="(item,index) in list" :key="index" @click="detailsBtn(item)">
				<view class="image">
					<image :src="item.goods_image" mode="aspectFill"></image>
				</view>
				<view class="info">
					<view class="name one-txt-cut">{{item.goods_name}}</view>
					<view class="stock">{{item.pay_money}}件</view>
					<view class="money">
						<text class="m_left">￥{{item.wyy}}</text>
						<text class="m_right">赠{{item.zhangfu}}%</text>
					</view>
					<view class="price">
						<view class="left">
							总价：<text class="tip">￥</text><text class="num">{{item.pay_money}}</text>
						</view>
						<view class="right" :class="item.is_qiang==1?'right_no':''">抢购</view>
					</view>
				</view>
			</view>
			<view class="mall_loading" style="padding-top: 20rpx;">
				<u-loadmore :status="status" color='#999' />
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		name:"goods_list",
		data() {
			return {
				type:1,
				page:1,
				list:[],
				//
				status: 'loadmore',//加载前值为loadmore，加载中为loading，没有数据为nomore
			};
		},
		mounted() {
			this.goodsList()
		},
		methods:{
			// 
			goodsList(){
				var that = this
				if(that.page==1){
					that.$tips.showLoading('加载中')
				}else{
					that.status = 'loading'
				}
				var params = {
					page:that.page,
					type:that.type
				}
				that.$httpApi.purchaseGoods(params).then((res)=>{
					if(res.code==1){
						if(that.page==1){
							that.list=[]
							that.$tips.hideLoading()
						}
						if(res.data.current_page==res.data.last_page){
							that.status = 'nomore'
						}else{
							that.status = 'loadmore'
						}
						that.list=that.list.concat(res.data.data)
					}
				})
			},
			// 
			refresh(val){
				this.type=val+1
				this.page=1
				this.goodsList()
			},
			// 滚动
			scrolltolower(){
				if(this.status=='nomore'){
					return
				}
				this.page++
				this.goodsList()
			},
			// 详情
			detailsBtn(info){
				if(info.is_qiang==1){
					return
				}else{
					uni.navigateTo({
						url:'/pages/mall/details_first?id='+info.id
					})
				}
			},
		}
	}
</script>

<style lang="less">
	.one_main{
		width: 100%;
		height: 100%;
		.scroll-Y{
			width: 100%;
			height: 100%;
			padding-top: 24rpx;
		}
		.list{
			margin-bottom: 1px;
			width: 100%;
			padding: 32rpx;
			background: #fff;
			display: flex;
			.image{
				width: 220rpx;
				height: 220rpx;
				image{
					display: block;
					width: 100%;
					height: 100%;
					border-radius:10rpx;
				}
			}
			.info{
				width: calc(100% - 220rpx);
				padding-left: 24rpx;
				height: 220rpx;
				.name{
					width: 100%;
					font-size: 32rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #222222;
				}
				.stock{
					width: 100%;
					padding-top: 8rpx;
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
				}
				.money{
					width: 100%;
					padding-top: 12rpx;
					display: flex;
					align-items: center;
					.m_left{
						font-size: 28rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #222222;
					}
					.m_right{
						padding-left: 32rpx;
						font-size: 28rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #26C281;
					}
				}
				.price{
					width: 100%;
					padding-top: 28rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					.left{
						display: flex;
						align-items: center;
						font-size: 28rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #222222;
						.tip{
							font-size: 24rpx;
							font-family: PingFang SC-Medium, PingFang SC;
							font-weight: 500;
							color: #FF6230;
							margin-top: 8rpx;
						}
						.num{
							font-size: 40rpx;
							font-family: PingFang SC-Medium, PingFang SC;
							font-weight: 500;
							color: #FF6230;
						}
					}
					.right{
						width: 120rpx;
						height: 56rpx;
						line-height: 56rpx;
						text-align: center;
						font-size: 28rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #FFFFFF;
						background: #26C281;
						border-radius: 60rpx
					}
					.right_no{
						background: #bbb;
					}
				}
			}
		}
	}
</style>